<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background-color: pink;
            padding: 10px;
        }
    </style>
</head>
<body>
    <div class="box" style="width: 200px;"></div>
    <script>
        //offset和style的区别
        var box=document.querySelector('.box');
        //只读 只是获取用offset
        console.log(box.offsetWidth);
        //可读可写 改值用style 获取只能获取行内的
        console.log(box.style.width);
        box.style.width="300px";
    </script>
</body>
</html>